
--[[
	消息处理

--]]



---------------------------------------------------------
-- class
---------------------------------------------------------
local Handler = class("Handler")

function Handler:ctor(name)
    self:register()
end


function Handler:register()
    self:callback("get_playing_num", self.getPlayingNum)
    self:callback("get_seating_num", self.getSeatingNum)

    self:callback("set_table_id", self.setTableId)
end

function Handler:onStart()
    print("Handler:onStart chess!")
    g.desk:start()
    --local user1 = g.user_manager:addUser(100)
    --user1:setCamp(1)
    --local user2 = g.user_manager:addUser(101)
    --user2:setCamp(-1)
end

--正在玩的人数
function Handler:getPlayingNum()
    local users = g.user_manager:getPlayingNum()
    local num = #users
    print("Handler:getPlayingNum ", num)
    return num
end

--坐着的人数
function Handler:getSeatingNum()
    local users = g.user_manager:getSeatUser()
    local num = #users
    print("Handler:getSeatUser ", num)
    return num
end

function Handler:setTableId(id)
    g.data.table_id = id
end

return Handler